﻿using ADSystem.AmazonControl;
using AmazonMODEL;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Xml.Serialization;

namespace ADSystem
{
    public partial class AmazonReleaseAD : Form
    {
        public AmazonReleaseAD()
        {
            InitializeComponent();
        }

        private void AmazonReleaseAD_Load(object sender, EventArgs e)
        {
            string name = typeof(HomeParentage).Name;
            List<string> list = Enum.GetNames(typeof(HomeParentage)).ToList();
            //this.flpEnum.Controls.Clear(); 
            //for (int i = 0; i < 20; i++)
            //{
            //    this.flpEnum.Controls.Add(new Label() { Anchor = AnchorStyles.Right, Name = name + i, Text = name + ":" });
            //    this.flpEnum.Controls.Add(new ComboBox() { Anchor = AnchorStyles.Left, Name = "cbx" + name + i, DropDownStyle = ComboBoxStyle.DropDownList, DataSource = list });
            //    if (i != 20)
            //    {
            //        int row = this.flpEnum.RowStyles.Add(new RowStyle() { SizeType = SizeType.AutoSize });
            //    }
            //}


        }
       

        private void btnQuery_Click(object sender, EventArgs e)
        {
           this.dgvProductList.DataSource=  SysController.ProductController.GetProduct();
        }

        /// <summary>
        /// 全选
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void chkSelectAll_CheckedChanged(object sender, EventArgs e)
        {
            for (int i = 0; i < dgvProductList.Rows.Count; i++)
            {
                dgvProductList.Rows[i].Cells["cSelect"].Value = chkSelectAll.Checked;
            }
        }

        /// <summary>
        /// 单选
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void dgvProductList_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex == -1) return;
            if (e.ColumnIndex == -1) return;
            if (dgvProductList.Columns[e.ColumnIndex].Name == "cSelect")
            {
                dgvProductList.CurrentCell.Value = !Convert.ToBoolean(dgvProductList.CurrentCell.Value);
            }
        }

        private void dgvProductList_MouseUp(object sender, MouseEventArgs e)
        {
            if (dgvProductList.SelectedRows.Count > 0)
            {
                //UTIL.DataGridViewMethod.SetGridCellValue(dgvProductList, 0, 0);
                dgvProductList.SelectedRows.Cast<DataGridViewRow>().ToList().ForEach(r => r.Cells[0].Value = 1);
            }
        }
         
    }
   
}
